﻿using System;
using fastCSharp.code.cSharp;
using System.Linq.Expressions;

namespace fastCSharp.sql.cache.whole.events
{
    /// <summary>
    /// 自增ID整表缓存
    /// </summary>
    /// <typeparam name="valueType">表格类型</typeparam>
    /// <typeparam name="modelType">模型类型</typeparam>
    public abstract class identityMemberMap<valueType, modelType, memberCacheType> : key<valueType, modelType, memberCacheType, int>
        where valueType : class, modelType
        where modelType : class
        where memberCacheType : class
    {
        /// <summary>
        /// 基础ID
        /// </summary>
        protected int baseIdentity;
        /// <summary>
        /// 缓存数据数量
        /// </summary>
        public int Count { get; protected set; }
        /// <summary>
        /// SQL操作缓存
        /// </summary>
        /// <param name="sqlTool">SQL操作工具</param>
        /// <param name="baseIdentity">基础ID</param>
        /// <param name="group">数据分组</param>
        protected identityMemberMap(fastCSharp.emit.sqlTable.sqlTool<valueType, modelType> sqlTool, Expression<Func<valueType, memberCacheType>> memberCache, int group, int baseIdentity)
            : base(sqlTool, memberCache, fastCSharp.emit.sqlModel<modelType>.IdentityGetter(baseIdentity), group)
        {
            this.baseIdentity = baseIdentity;
        }
    }
}
